#include "./compr.h"
#include "../../device/gpio.h"


namespace driver {

using namespace device::gpio;

using COMPR = PB<13>;

Compr::Compr() {
    RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;

    config_pp_out<COMPR>();
    close();
}

bool Compr::open() {
    if (!m_close_prog.is_after(OPEN_DURATION)) {
        return false;
    }
    COMPR::set();
    m_open_flag = true;
    return true;
}

void Compr::close() {
    m_close_prog.reset();
    COMPR::clr();
    m_open_flag = false;
}

}
